<?php
$in_categories = array();
if (count($cat_list) > 0) { ?>
	<div style="padding:0px 0px 10px 0px;">
		<table border="0" style="width:100%;" cellpadding="0" cellspacing="0">
			<colgroup>
				<col width="50px" />
				<col width="30px" />
				<col />
			</colgroup>
			<tr>
				<td class="grid_header"><?php echo __('Id'); ?></td>
				<td class="grid_header">&nbsp;</td>
				<td class="grid_header"><?php echo __('Document found in next categories'); ?></td>
			</tr>
			<?php
			foreach ($cat_list as $category) {
				$in_categories[] = $category['id']; ?>
				<tr>
					<td class="grid_cell"><?php echo $category['id']; ?></td>
					<td class="grid_cell">
						<a href="<?php echo BASE_URL; ?>document/categories/<?php echo $doc_id; ?>/<?php echo $category['id']; ?>/2" class="grid_link">
							<img src="<?php echo PUBLIC_URL; ?>images/minus.png" style="display:block; border:none;" alt="<?php echo __('Remove from category'); ?>" title="<?php echo __('Remove from category'); ?>" />
						</a>
					</td>
					<td class="grid_cell">
						<?php echo $category['path']; ?>
					</td>
				</tr>
			<?php } ?>
		</table>
	</div>
<?php } ?>

<div>
<?php if (count($full_cat_list) > 0) { ?>
	<table border="0" style="width:100%;" cellpadding="0" cellspacing="0">
		<colgroup>
			<col width="50px" />
				<col width="30px" />
			<col />
		</colgroup>
		<tr>
			<td class="grid_header"><?php echo __('Id'); ?></td>
			<td class="grid_header">&nbsp;</td>
			<td class="grid_header"><?php echo __('Tree view'); ?></td>
		</tr>
		<?php
		foreach ($full_cat_list as $category) {
			if (!$category['level']) { continue; }?>
			<tr>
				<td class="grid_cell"><?php echo $category['id']; ?></td>
				<td class="grid_cell">
				<?php if (!in_array(intval($category['id']), $in_categories)) { ?>
					<a href="<?php echo BASE_URL; ?>document/categories/<?php echo $doc_id; ?>/<?php echo $category['id']; ?>/1" class="grid_link">
						<img src="<?php echo PUBLIC_URL; ?>images/plus.png" style="display:block; border:none;" alt="<?php echo __('Add to category'); ?>" title="<?php echo __('Add to category'); ?>" />
					</a>
				<?php } else { ?>
					<a href="<?php echo BASE_URL; ?>document/categories/<?php echo $doc_id; ?>/<?php echo $category['id']; ?>/2" class="grid_link">
						<img src="<?php echo PUBLIC_URL; ?>images/minus.png" style="display:block; border:none;" alt="<?php echo __('Remove from category'); ?>" title="<?php echo __('Remove from category'); ?>" />
					</a>
				<?php } ?>
				</td>
				<td class="grid_cell" style="padding-left:<?php echo (($category['level'] - 1) * 15) + 5; ?>px;">
					<?php echo $category['name']; ?>
				</td>
			</tr>
			<?php
		} ?>
	</table>
<?php } else {
	echo __('No categories found');
} ?>
</div>